package adapters;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.administrator.newxlmedical.R;
import com.example.administrator.newxlmedical.ReturnHintActivity;

import java.util.List;

import beans.ReturnHintBean;
import beans.UnusedGoodsBean;
import butterknife.BindView;
import butterknife.ButterKnife;
import custom.BaseRecyclerAdapter;

/**
 * Created by Administrator on 2018/5/22.
 */

public class ReturnHintAdapter extends BaseRecyclerAdapter<ReturnHintAdapter.ReturnHintViewHolder> {
    private Context mContext;
    private LayoutInflater inflater;
   private List<ReturnHintBean> list;
//    private OnClickListener onClickListener;

    public ReturnHintAdapter(Context mContext, List<ReturnHintBean> list) {
        this.mContext = mContext;
        inflater = LayoutInflater.from(mContext);
        this.list = list;
    }

    @Override
    public ReturnHintViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        ReturnHintViewHolder viewHolder = new ReturnHintViewHolder(inflater.inflate(R.layout.adapter_return_hint, parent, false));

        return viewHolder;
    }

    @Override
    public void onBindViewHolder(final ReturnHintViewHolder holder, final int position) {
        ReturnHintBean bean = list.get(position);
        holder.returnGoods.setText(bean.getGoodsName());
        holder.returnSize.setText(bean.getSpecification());
        holder.returnDataEnd.setText(bean.getTakeTime());
        holder.returnSupplier.setText(bean.getManufacturer());
        holder.returnOperator.setText(bean.getOperator());
        holder.returnCount.setText(bean.getNumber());
        if (position % 2 == 0) {
            holder.rlTitle.setBackgroundColor(mContext.getResources().getColor(R.color.partLineBackground));
        } else {
            holder.rlTitle.setBackgroundColor(mContext.getResources().getColor(R.color.white));
        }
        if (bean.isNoReturn()){
            holder.returnDataEnd.setTextColor(mContext.getResources().getColor(R.color.red_1));
        }else {
            holder.returnDataEnd.setTextColor(mContext.getResources().getColor(R.color.textview_default_color));
        }

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class ReturnHintViewHolder extends BaseRecyclerAdapter.BaseViewHolder {
        @BindView(R.id.rl_title)
        LinearLayout rlTitle;
        @BindView(R.id.return_goods)
        TextView returnGoods;
        @BindView(R.id.return_size)
        TextView returnSize;
        @BindView(R.id.return_supplier)
        TextView returnSupplier;
        @BindView(R.id.return_count)
        TextView returnCount;
        @BindView(R.id.return_operator)
        TextView returnOperator;
        @BindView(R.id.return_data_end)
        TextView returnDataEnd;

        public ReturnHintViewHolder(View itemView) {
            super(itemView);
        }
    }

}
